import java.io.File;

import org.junit.Test;

import GoldenEagle.DataProvider;
import GoldenEagle.Menu;
import GoldenEagle.MenuSubject;
import GoldenEagle.MenuSystem;

import junit.framework.TestCase;



public class TestMenu extends TestCase{
	@Test
	public void testGetData(){
		System.out.println("\n[testGetData]");
		
		DataProvider.praseFromFile(new File(Menu.getDefaultMenuFilePath()) );
		//Menu menu = TestMenu.InitMenu();
		String introduction = DataProvider.getData("TestDataGet");
		System.out.println(introduction+"\n");
		assertTrue(introduction.equals("DataGetFirstLineDataGet2Line\\nLine2"));
	}
	public static Menu InitMenu()
	{
		String filePath = Menu.getDefaultMenuFilePath();
		return new Menu(new File(filePath));
	}
	@Test
	public void testDisplayMenu()
	{
		System.out.println("\n[testDisplayMenu]");
		
		Menu menu = TestMenu.InitMenu();
		assertFalse(menu.getMenuList(true).isEmpty());
	}
	@Test
	public void testGetMenuSubjectByIndex()
	{
		System.out.println("[testGetMenuSubjectByIndex]");
		
		Menu menu = TestMenu.InitMenu();
		MenuSubject ms = menu.getMenuSubject(1);
		
		assertEquals(ms.getName(),"Singapore Rice Vermicelli");
		assertEquals(ms.getPrice(),58f);
		
		System.out.println("index 1 MenuSubject is named: " + ms.getName() +" and it's price is "+ ms.getPrice() +"$");
	}
	@Test
	public void testGetMenuSubjectByName()
	{
		System.out.println("[testGetMenuSubjectByName]");
		
		Menu menu = TestMenu.InitMenu();
		MenuSubject ms = menu.getMenuSubject("Salted-Fish and Eggplant Rice Vermicelli");
		
		assertEquals(menu.getIndex(ms),2);
		assertEquals(ms.getPrice(),58f);
		
		System.out.println("the index of Salted-Fish and Eggplant Rice Vermicelli is " + menu.getIndex(ms) +" and it's price is "+ ms.getPrice() +"$");
	}

}
